Skip to content

Organization Validation for Service Inventory - #1668

Open
JVickery-TBS wants to merge 58 commits into
masterfrom
feature/ds-reference-tables
Open

Organization Validation for Service Inventory#1668
JVickery-TBS wants to merge 58 commits into
masterfrom
feature/ds-reference-tables

Conversation

@JVickery-TBS

Copy link
Copy Markdown
Contributor

We are able to consistently use the releases from the SI github to generate the CSV ref data we need. We have commands which load it into the tables which we define in an sql script in here. The part we were tripped on was relation between Service IDs and Program IDs, but there is no relation that is being defined or maintained currently so don't have to worry about that.

Just extended the temp datastore table to add an optional org_name to it, which we then use in the triggers. The Service ID one works fine, need to make the error message for it still.

The Program IDs one is gunna be interesting as Program IDs is a multiple select.

- Started working on reference tables for pd data.
- Continued script to generate service reference data.
- Continued schema for ref tables.
- Improved pd subcommand for loading ref data.
- Finalized script to generate service ref data.
- Added more recombinant schema key/values.
- Made JSONB index.
- Added choices_filter_query.
- Added recombinant org_name to the temp ds table.
- Started writing the database validation.
Comment thread ckanext/canada/plugin/internal_plugin.py Outdated
- Finalized ref value checks and errors in the db func.
- Fixed up some other logic things.
- Started working on fiscal year function.
- Finalized fiscal year db function.
Comment thread bin/service_generate_reference_data.py Outdated
Comment thread ckanext/canada/tables/service.yaml Outdated
Comment thread ckanext/canada/tables/service.yaml Outdated
Comment thread ckanext/canada/tables/service.yaml Outdated
@wardi

wardi commented Apr 18, 2026

Copy link
Copy Markdown
Member

just those minor things otherwise LGTM

- Added change log file.
- Pyright fixes.
- Flake8 fixes.
- Made service name fields computed ones.
- Modified filter scripts for service name lookups.
- Filter script typo.
- Filter script typo.
@codecov

codecov Bot commented Apr 20, 2026

Copy link
Copy Markdown

❌ 4 Tests Failed:

Tests completed Failed Passed Skipped
309 4 305 0
View the top 3 failed test(s) by shortest run time
ckanext/canada/tests/test_service.py::TestService::test_required_fields
Stack Traces | 0.005s run time
self = <ckanext.canada.tests.test_service.TestService object at 0x7fe17af6b280>

    def test_required_fields(self):
        """
        Excluding required fields should raise an exception
        """
        chromo = get_chromo('service')
        record = chromo['examples']['record'].copy()
    
        expected_required_fields = ['service_description_en', 'service_description_fr',
                                    'service_type', 'service_recipient_type',
                                    'service_scope', 'client_target_groups',
                                    'program_id', 'client_feedback_channel',
                                    'automated_decision_system', 'service_fee',
                                    'os_account_registration', 'os_authentication',
                                    'os_application', 'os_decision', 'os_issuance',
                                    'os_issue_resolution_feedback', 'sin_usage',
                                    'cra_bn_identifier_usage', 'num_phone_enquiries',
                                    'num_applications_by_phone', 'num_website_visits',
                                    'num_applications_online', 'num_applications_in_person',
                                    'num_applications_by_mail', 'num_applications_by_email',
                                    'num_applications_by_fax', 'num_applications_by_other']
    
        for field in chromo['fields']:
            if field['datastore_id'] in chromo['datastore_primary_key']:
                continue
            if field.get('excel_required') or field.get('form_required'):
>               assert field['datastore_id'] in expected_required_fields
E               AssertionError: assert 'service_name_en' in ['service_description_en', 'service_description_fr', 'service_type', 'service_recipient_type', 'service_scope', 'client_target_groups', ...]

.../canada/tests/test_service.py:119: AssertionError
ckanext/canada/tests/test_service.py::TestStdService::test_required_fields
Stack Traces | 0.039s run time
self = <ckanext.canada.tests.test_service.TestStdService object at 0x7f1ae06c7040>

    def test_required_fields(self):
        """
        Excluding required fields should raise an exception
        """
        self._make_parent_record()
        chromo = get_chromo('service-std')
        record = chromo['examples']['record'].copy()
    
        expected_required_fields = ['service_standard_en', 'service_standard_fr',
                                    'type', 'channel', 'standards_targets_uri_en',
                                    'standards_targets_uri_fr']
    
        for field in chromo['fields']:
            if field['datastore_id'] in chromo['datastore_primary_key']:
                continue
            if field.get('excel_required') or field.get('form_required'):
>               assert field['datastore_id'] in expected_required_fields
E               AssertionError: assert 'service_name_en' in ['service_standard_en', 'service_standard_fr', 'type', 'channel', 'standards_targets_uri_en', 'standards_targets_uri_fr']

.../canada/tests/test_service.py:595: AssertionError
ckanext/canada/tests/test_service.py::TestStdService::test_max_chars
Stack Traces | 0.576s run time
self = <ckanext.canada.tests.test_service.TestStdService object at 0x7fef25c0d610>

    def test_max_chars(self):
        """
        Over max character field values should raise an exception
        """
        self._make_parent_record()
        chromo = get_chromo('service-std')
        record = chromo['examples']['record'].copy()
    
        expect_maxchar_fields = ['service_standard_en', 'service_standard_fr',
                                 'channel_comments_en', 'channel_comments_fr',
                                 'comments_en', 'comments_fr',
                                 'standards_targets_uri_en',
                                 'standards_targets_uri_fr',
                                 'performance_results_uri_en',
                                 'performance_results_uri_fr']
    
        for field in chromo['fields']:
            if field.get('max_chars'):
>               assert field['datastore_id'] in expect_maxchar_fields
E               AssertionError: assert 'service_name_en' in ['service_standard_en', 'service_standard_fr', 'channel_comments_en', 'channel_comments_fr', 'comments_en', 'comments_fr', ...]

.../canada/tests/test_service.py:767: AssertionError
ckanext/canada/tests/test_service.py::TestService::test_max_chars
Stack Traces | 0.958s run time
self = <ckanext.canada.tests.test_service.TestService object at 0x7f53f47ff7f0>

    def test_max_chars(self):
        """
        Over max character field values should raise an exception
        """
        chromo = get_chromo('service')
        record = chromo['examples']['record'].copy()
    
        expect_maxchar_fields = ['service_description_en', 'service_description_fr',
                                 'automated_decision_system_description_en',
                                 'automated_decision_system_description_fr',
                                 'os_comments_client_interaction_en',
                                 'os_comments_client_interaction_fr',
                                 'special_remarks_en', 'special_remarks_fr',
                                 'service_uri_en', 'service_uri_fr']
    
        for field in chromo['fields']:
            if field.get('max_chars'):
>               assert field['datastore_id'] in expect_maxchar_fields
E               AssertionError: assert 'service_name_en' in ['service_description_en', 'service_description_fr', 'automated_decision_system_description_en', 'automated_decision_system_description_fr', 'os_comments_client_interaction_en', 'os_comments_client_interaction_fr', ...]

.../canada/tests/test_service.py:406: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

- Created new workflow to semi-automate stuffs.
- Removed service name computed fields.
- Trigger type cast.
- Rebuild service inventory ref data.
- Add fixme comment for overwritting dict assignment.
- Support multiple org names for one umd.
- Do not count new lines in max char func.
- Added test coverage.
- Added functionality for the new recombinant CLI markers.
- Added choice suffix to service inventory program_id.
- Added test coverage.
- Added support for old choice values in the recombinant webforms.
- If `service_migration` marker is set, invalid program_ids will be suffixed with -INV.
- Renamed the datastore_user temp table to be more accurate as an app_context table.
- Better handle legacy choices.
- Better handle choice suffixing.
- Handle insecure firefox preventing window.confirm
- Added change log files.
- Pyright fixes.
- Flake8 fixes.
- Pyright fixes.
- Flake8 fixes.
Comment thread bin/filter/filter_service.py Outdated
Comment thread bin/filter/filter_service.py Outdated
Comment thread bin/service_generate_reference_data.py Outdated
Comment thread bin/service_generate_reference_data.py
Comment thread ckanext/canada/logic.py Outdated
Comment thread ckanext/canada/triggers.py Outdated
Comment thread ckanext/canada/model.py Outdated
- Various changes from feedback.
- Change contextual datastore flags to just be one text[] db field.
- Improved suffix choices.
- Minor logic changes for service inventory suffixes.
- Fix newlines not displaying in pd datatables.
- Pytests don't like f string.
- Flake8 fixes.
- Test fix for db func change.
- Pyright fixes.
@JVickery-TBS
JVickery-TBS requested a review from wardi August 4, 2026 20:15
@JVickery-TBS

Copy link
Copy Markdown
Contributor Author

@wardi I think this is ready for another review now.

Comment thread ckanext/canada/assets/datatables/pd_datatables.js
@wardi

wardi commented Aug 16, 2026

Copy link
Copy Markdown
Member

otherwise LGTM

# Conflicts:
#	.github/workflows/pytest.yml
#	ckanext/canada/assets/public/canada_public.css
### RESOLVED.
- Bypass validation during migrations.
- Bring back service names.
- Fix truncating ref data tables.
- Add command option to ignore file hashes.
- Form prefix code for service_id fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants